const path = require('path')
const BASE_URL = process.env.BASE_URL || '/'
function resolve (dir) {
  return path.join(__dirname, dir)
}
if (!BASE_URL.startsWith('/')) {
  console.error('Please, use an absolute BASE_URL ')
  process.exit(1)
} else if (!BASE_URL.endsWith('/')) {
  console.error("BASE_URL  should end in '/'")
  process.exit(1)
}

module.exports = {
  publicPath: BASE_URL,
  configureWebpack: {
    resolve: {
      alias: {
        '@': resolve('src'),
        _v: resolve('src/views'),
        _c: resolve('src/components'),
        esri: '@arcgis/core'
      }
    }
  }
}
